package com.service.oss.controller;

import com.service.oss.service.OssService;
import com.service.utils.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RestController
@Api(description = "阿里云oss上传文件")
@RequestMapping("oss")
public class OssController {

    @Autowired
    private OssService ossService;

    @PostMapping("upload")
    @ApiOperation("文件上传")
    public ResultVo upload(@ApiParam(name = "file",value = "文件",required = true) @RequestParam("file") MultipartFile file){
       String url =   ossService.upload(file);
       return ResultVo.ok().data("url",url);
    }

}
